package com.motorwaymanage.actions;

import java.util.List;

import com.motorwaymanage.beans.JsonObject;
import com.motorwaymanage.beans.MaintainerInfo;
import com.motorwaymanage.biz.IMaintainerInfoBiz;
import com.motorwaymanage.impl.MaintainerInfoBizImpl;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class MaintainerInfoAction extends ActionSupport implements ModelDriven<MaintainerInfo>{
	
	private static final long serialVersionUID = 1L;
	private IMaintainerInfoBiz miInfoBiz=new MaintainerInfoBizImpl();
	private MaintainerInfo mi;
	private JsonObject json;
	
	public String selectOneStaff(){
		MaintainerInfo oneMi=miInfoBiz.selectOneStaff(mi.getMid());
		if(oneMi!=null){
			json=new JsonObject();
			json.setObj(oneMi);
			return SUCCESS;
		}
		return null;
	}
	
	public String getAllStaff() {
		List<MaintainerInfo> list = miInfoBiz.getAllStaff();
		if(list != null) {
			json = new JsonObject();
			json.setRows(list);
			return SUCCESS;
		}
		return null;
	}
	
	public String addStaffInfo() {
		json = new JsonObject();
		json.setResult(miInfoBiz.addStaffInfo(mi));
		return SUCCESS;
	}
	
	public String delStaffInfo() {
		json = new JsonObject();
		json.setResult(miInfoBiz.delStaffInfo(mi.getMid()));
		return SUCCESS;
	}
	
	public JsonObject getJson() {
		return json;
	}

	@Override
	public MaintainerInfo getModel() {
		if(mi==null){
			return mi=new MaintainerInfo();
		}
		return mi;
	}
}
